package cn.sc.summer.constant.util;

import cn.hutool.extra.spring.SpringUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.commons.util.InetUtils;
import org.springframework.stereotype.Component;

/**
 * 类名：默认IP工具类
 *
 * @author a-xin
 * @date 2024/8/26 11:19
 */
@Slf4j
@Component
public class BaseIpUtil {

    /**
     * 获取nacos对应服务实例ip
     *
     * @return nacos服务实例ip
     */
    public static String getNacosInstanceIp() {
        InetUtils inetUtils = SpringUtil.getBean("inetUtils", InetUtils.class);
        return inetUtils.findFirstNonLoopbackHostInfo().getIpAddress();
    }

}
